define(function(){
    
	return {
		//轮播图
	    bannerJX : function(res){
	   	  	//轮播图数组
		    var imgArr = [];
		    var i = 0;
		    for(let i=0;i<res.length;i++){
		      imgArr[i] = res[i].activity.img;
		    }
		      
			var $img = $('.banner img');
		    setInterval(function(){
				i++;
				$img.attr('src',imgArr[i]);
				if(i==1){
			   		i=-1;
				}      	
	      	},2500); 	
	    },
		//四张图片
	    Main_oneJX :function (res){
	      var $home_main_one = $('<div></div>').addClass('home_main_one').css({
	        "display" : "flex",
	        "alignItems" : "center",
	        "justifyContent" : "space-around",
	        "backgroundColor" : "#fff",
	        "height" : "1.6rem",
	        'margin' : '0.25rem 0'
	      });
	      for(let i=0;i<res.length;i++){
			var $home_main_top_itemsWrap = $('<div></div>').addClass('home_main_top_itemsWrap').css('textAlign','center');
			var $home_main_top_img = $('<img>').attr('src',res[i].activity.img).css('height','1rem');
			var $home_main_top_p = $('<p></p>').text(res[i].activity.name).css('fontSize','.2rem');
			
			$home_main_top_img.appendTo($home_main_top_itemsWrap);
			$home_main_top_p.appendTo($home_main_top_itemsWrap);
			$home_main_top_itemsWrap.appendTo($home_main_one);
	      }
	      $home_main_one.appendTo($('.home_main'));
	
	    },
	   	//现货直供   
	    Main_twoJX : function (res){
	    	var $home_main_two = $('<div></div>').addClass('home_main_two').css({
	        "display" : "flex",
	        "alignItems" : "center",
	        "justifyContent" : "space-around",
	        'marginBottom' : '0.25rem'
	      });
	    	for(let i=0;i<res.length-1;i++){
			var $home_main_two_itemsWrap = $('<div></div>').addClass('home_main_two_itemsWrap').css({
				'flexBasis' : '34%',
				'height' : '2rem'
				
			});
			var $home_main_two_img = $('<img>').attr('src',res[i].activity.img).width('100%').height('100%');
			
			$home_main_two_img.appendTo($home_main_two_itemsWrap);
			$home_main_two_itemsWrap.appendTo($home_main_two);
	      }
	      $home_main_two.appendTo($('.home_main'));
	    	
	      
	    },
		//便利店
		Main_threeJX : function (res){
			var $home_main_three = $('<div></div>').addClass('home_main_three').css({
	        'background' : '#fff'
	     });
	     
	      	var $home_main_three_top = $('<div></div>').addClass('home_main_three_top').css({
	      		'background' : 'url('+res[0].act_rows[0].chead_detail.img+') no-repeat center center',
	      		'backgroundSize' : '100%',
	      		'height' : '1rem'
	      	});
	      	
	      	var $home_main_three_center_top = $('<div></div>').addClass('home_main_three_center_top').css({
	      		'display' : 'flex',
	      		"alignItem" : 'center',
	      	});
	      	
	      	for(let i=0;i<res[1].act_rows.length;i++){
	      		var $home_main_three_center_top_img = $('<img>').attr('src',res[1].act_rows[i].cactivity_detail.img).css({
	      			'width' : '45%',
	      			'height' : '10%',
	      			'marginLeft' : '.2rem'
	      		}).appendTo($home_main_three_center_top);
	      	}
	      	
	      	var $home_main_three_center_bot = $('<ul></ul>').addClass('home_main_three_center_bot').css({
	      		'display' : 'flex',
	      		"alignItem" : 'center',
	      		'justifyContent' : 'space-around',
	      		'padding' : '.2rem 0 .4rem 0',
	      		'borderBottom' : '0.01rem solid #ccc'
	      	});
	      	
	      	for(let i=0;i<res[2].act_rows.length;i++){
	      		var $home_main_three_center_bot_items = $('<li></li>').addClass('home_main_three_center_bot_items').css({
	      		'textAlign' : 'center'
	      	});
	      		var $home_main_three_center_bot_img = $('<img>').attr('src',res[2].act_rows[i].cicons_detail.img).css({
	      			'width' : '100%',
	      		}).appendTo($home_main_three_center_bot_items);
	      		
	      		var $home_main_three_center_bot_p = $('<li></li>').addClass('home_main_three_center_bot_p').text(res[2].act_rows[i].cicons_detail.name).css({
	      			'fontSize' : '.2rem'
	      		}).appendTo($home_main_three_center_bot_items);
	      		
	      		$home_main_three_center_bot_items.appendTo($home_main_three_center_bot);
	      		
	      	}
	      	
	      	var $home_main_three_bot = $('<div></div>').addClass('home_main_three_bot').css({
	      		'display' : 'flex',
	      		"alignItem" : 'center',
	      	});
	      	
	      	for(let i=0;i<res[3].act_rows.length;i++){
	      		var $home_main_three_bot_img = $('<img/>').attr('src',res[3].act_rows[i].activity.img).css({
	      			'width' : '50%',
	      			'height' : '100%'
	      		}).appendTo($home_main_three_bot);
	      	}
	      	     	
	      	$home_main_three_top.appendTo($home_main_three);
	      	$home_main_three_center_top.appendTo($home_main_three);
	      	$home_main_three_center_bot.appendTo($home_main_three);
	      	$home_main_three_bot.appendTo($home_main_three);
	      	$home_main_three.appendTo($('.home_main'));
		},
		//主内容
		Main_fourJX : function (res){
			for(let i=0;i<res.length;i++){
				var $home_main_four = $('<div></div>').addClass('home_main_four').css({
	        		'background' : '#fff',
	        		'margin' : '.3rem 0',
	     		});
		    	//上半部分
		    	var $home_main_four_topWrap = $('<div></div>').addClass('home_main_four_topWrap').css({
		        	'padding' : '0.3rem 0 0 0',
		        	'height' : '1rem'
		     });
		     	var color = '#'+parseInt(Math.random()*999999+100000);
		    	$('<p></p>').text(res[i].category_detail.name).css({
		    		'fontSize' : '.27rem',
		    		'fontWeight' : 'bold',
		    		'color' : color,
		    		'float' : 'left',
		    		'paddingLeft' : '.2rem',
		    		'marginLeft' : ".2rem",
		    		'borderLeft' : '.18rem solid ' 
		    	}).appendTo($home_main_four_topWrap);
		    	
		    	$('<p></p>').text('更多').css({
		    		'fontSize' : '.24rem',
		    		'color' : 'grey',
		    		'float' : 'right',
		    		'paddingRight' : '.4rem',
		    		'background' : 'url(./home/images/moreBg.png) no-repeat .6rem center',
		    		'backgroundSize' : '40%'
		    		
		    	}).appendTo($home_main_four_topWrap);
		    	
		    	
		    	//中间广告条
		    	var $home_main_four_centerWrap = $('<div></div>').addClass('home_main_four_centerWrap').css({
		        	'background': 'url('+ res[i].activity.img +') no-repeat center top',
		    		'backgroundSize': '94%',
		    		'paddingBottom': '23.84%',
		    		'marginBottom': '.2rem'
		     	});
		     	
		     	//下半部分商品展示
		     	var $home_main_four_botWrap = $('<ul></ul>').addClass('home_main_four_botWrap').css({
		     		'display' : 'flex',
		     		'align-item' : 'center',
		     		'padding-bottom' : '.15rem'
		     	});
		     	
		     	for(let j=0;j<res[i].category_detail.goods.length;j++){
		     		var $home_main_four_botItemsWrap = $('<li></li>').addClass('home_main_four_botItemsWrap').css({
		     			'flexBasis' : '30%'
		     		});
		     		
		     		if(j==1){
		     			$home_main_four_botItemsWrap.css({
		     				'border-left' : '1px solid #ccc',
		     				'border-right' : '1px solid #ccc',
		     			})
		     		}
		     		//商品图片
		     		var $home_main_four_bot_imgWrap = $('<div></div>').addClass('home_main_four_imgWrap').css({
		     			'height' : '2rem',
		     			'width' : '100%'
		     		});
		     		$('<img>').attr('src',res[i].category_detail.goods[j].app_mimg).css({
		     			'width' : '100%',
		     			'height' : '100%'
		     		}).appendTo($home_main_four_bot_imgWrap);
		     		
		     			$home_main_four_bot_imgWrap.appendTo($home_main_four_botItemsWrap);
		     		//商品信息
		     		var $home_main_four_bot_proWrap = $('<div></div>').addClass('home_main_four_proWrap');
		     		//商品名
		     		$('<p></p>').text(res[i].category_detail.goods[j].long_name).css({
		     			'font-size' : '.23rem',
		     			'white-space' : 'nowrap',
		     			'text-overflow' : 'ellipsis',
		     			'overflow' : 'hidden',
		     			'margin' : '0 .15rem',
		     			'width' : '1.8rem'
		     		}).appendTo($home_main_four_bot_proWrap);
		     		
		     		//精选
		     		$('<p></p>').text('精选').css({
		     			'font-size' : '.23rem',
		     			'margin' : '.15rem 0 .15rem .15rem',
		     			'color' : 'red',
		     			'width' : '.6rem',
		     			'text-align' : 'center',
		     			'border' : '1px solid red',
		     			'border-radius' : '.1rem'
		     		}).appendTo($home_main_four_bot_proWrap);
		     		//商品重量
		     		$('<p></p>').text(res[i].category_detail.goods[j].specifics).css({
		     			'font-size' : '.23rem',
		     			'margin' : '.12rem .15rem',
		     			'color' : 'grey'
		     		}).appendTo($home_main_four_bot_proWrap);
		     		//商品价格
		     		$('<p></p>').text('¥'+res[i].category_detail.goods[j].partner_price).css({
		     			'font-size' : '.23rem',
		     			'margin' : '0 .15rem',
		     			'color' : '#f40',
		     			'float' : "left"
		     		}).appendTo($home_main_four_bot_proWrap);
		     		$('<p></p>').text(res[i].category_detail.goods[j].market_price).css({
		     			'font-size' : '.23rem',
		     			'color' : 'grey',
		     			'text-decoration' : 'line-through',
		     			'float' : "left"
		     		}).appendTo($home_main_four_bot_proWrap);
		     		
		     		//购买按钮
		     		$('<span></span>').text('+').css({
		     			'fontSize' : '.45rem',
		     			'color' : 'red',
		     			'width' : '.5rem',
		     			'height' : '.5rem',
		     			'line-height' : '.45rem',
		     			'text-align' : 'center',
		     			'fontWeight' : 'bolder',
		     			'border' : '1px solid #ccc',
		     			'border-radius' : '50%',
		     			'float' : 'right',
		     			'margin' : ' -0.1rem .1rem .15rem 0'
		     		}).appendTo($home_main_four_bot_proWrap);
		     			
		     		$home_main_four_bot_proWrap.appendTo($home_main_four_botItemsWrap);
		     		$home_main_four_botItemsWrap.appendTo($home_main_four_botWrap);
		     	}
		     	    	
		    	$home_main_four_topWrap.appendTo($home_main_four);
		    	$home_main_four_centerWrap.appendTo($home_main_four);
		    	$home_main_four_botWrap.appendTo($home_main_four);
		    		
		    	$home_main_four.appendTo($('.home_main'));    	
				}		    	  	
		}

	}
});
